package top.kaoshanji.ch12web;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 代码清单 ch12-01：Servlet版本HelloClient
 * author kaoshanji
 * ^_^
 * create time 2024/11/21 16:59
 */
@WebServlet(urlPatterns = "/hello")
public class HelloClient extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        resp.setContentType("text/html");
        resp.setCharacterEncoding("UTF-8");

        PrintWriter pw = resp.getWriter();
        pw.println(
                "<html><head><title>Hello Client!</title></head><body>"
                        + "<h1>Hello Client!</h1>"
                        + "</body></html>" );
        pw.flush();

    }

}
